<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/views/pagelet/page-includes.jsp"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta
	content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"
	name="viewport">
</head>
<body class="hold-transition skin-blue sidebar-mini">
			<section class="content" style="align-content: center">
<!-- 内容开始 -->
				<div>
					<form class="form-horizontal">
						<div class="box-body">
							<div class="form-group bs-valid rowStyle">
								<label for="dictCode" class="control-label">系统参数编码: </label>
								<input type="text" class="form-control" id="paramCode" name="paramCode" value="${sysParam.paramCode }">
							</div>
							<div class="form-group bs-valid rowStyle">
								<label for="dictValue" class="control-label">系统参数值: </label>
								<input type="text" class="form-control" id="paramVal" name="paramVal" value="${sysParam.paramVal }">
							</div>
						</div>
						<div class="box-footer text-center">
							<input type="hidden" id="id" name="id" value="${sysParam.id }" />
							<button type="button" class="btn btn-primary saveBtn" onclick="save()">保存</button>
						</div>
					</form>
				</div>
<!-- 内容结束 -->
			</section>
</body>

<script type="text/javascript">

var index = parent.layer.getFrameIndex(window.name);

onload = function(){
	var id = "${sysParam.id }";
	if(id != null && id != ""){
		$("#paramCode").attr({"disabled":"disabled"});
	}
	
	
	//添加校验表单
	$('.form-horizontal').bootstrapValidator({
		message: '输入错误',
		feedbackIcons: {
            valid: 'glyphicon glyphicon-ok',
            invalid: 'glyphicon glyphicon-remove',
            validating: 'glyphicon glyphicon-refresh'
        },
        fields: {
        	paramCode : {
        		validators : {
        			notEmpty: {message: '系统参数编码不能为空'},
                    regexp: {regexp: /^[a-zA-Z0-9]{1,50}$/,message: '系统参数编码为1~50个字母或者数字'}
        		}
        	},
        	paramVal : {
        		validators : {
        			notEmpty: {message: '系统参数值不能为空'},
                    regexp: {regexp: /^[a-zA-Z0-9_\u4e00-\u9fa5]{1,100}$/,message: '系统参数值描述为1~100个字符，不能包含特殊字符'}
        		}
        	}
        }
	})
}


function save() {
	$('.form-horizontal').bootstrapValidator('validate');
	if(!$('.form-horizontal').data('bootstrapValidator').isValid()) return;
	var id = "${sysParam.id }";
	var flag = "";
	if(id != null && id != ""){
		flag = "UPDATE";
	}
	$.ajax({
		type: "POST",
		url: webroot + "/sysparam/modify?showtype=" + flag,
		data:$('.form-horizontal').serialize(),
		dataType: "json",
		success: function(resp){
			if(resp.success){
				app.print.success("保存成功!", index,null)
			} else {
				app.print.error(resp.message, null, null);
			}
		}
	});
}
</script>

</html>
